<%@ page import="org.springframework.beans.factory.InitializingBean" %>
<%@ page import="org.springframework.web.context.WebApplicationContext" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%--
  更新缓存
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);

    String refreshType = request.getParameter("type");
    String beanName;
    if ("carBrands".equalsIgnoreCase(refreshType)) {
        beanName = "carBrandQueryService";
    } else if ("wmi".equalsIgnoreCase(refreshType)) {
        beanName = "vinAnalyserFactory";
    } else {
        response.getWriter().write("Nothing ever happened.");
        return;
    }
    InitializingBean service = (InitializingBean) context.getBean(beanName);
    try {
        service.afterPropertiesSet();
    } catch (Exception e) {
        e.printStackTrace(response.getWriter());
    }
    response.getWriter().write("Done.");
%>
